package com.jyw.system.domain.vo;

import com.jyw.system.domain.SysTeam;
import com.jyw.system.domain.SysUserTeam;
import com.jyw.system.utils.DeptUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author 沈峻
 * @ClassName DeptTeamUserTreeVo
 * @Description TODO
 * @Date 2023/9/6 15:11
 **/
@Data
@ApiModel("部门小组用户联动对象")
@NoArgsConstructor
public class DeptTeamUserTreeVo {
    @ApiModelProperty("部门id")
    private Long deptId;

    @ApiModelProperty("部门名称")
    private String deptName;

    @ApiModelProperty("小组集合")
    private List<DeptTeamVo> teamList;

    public DeptTeamUserTreeVo(Map.Entry<Long, List<SysTeam>> entry, List<SysUserTeam> userTeamList) {
        setDeptId(entry.getKey());
        //设置部门名称
        setDeptName(DeptUtils.deptIdToPathName(entry.getKey()));
        //设置小组
        setTeamList(entry.getValue().stream().map(data->new DeptTeamVo(data,userTeamList)).collect(Collectors.toList()));

    }
}
